[各大厂家支持EtherCAT]-Matlab-xPC方案

友情提示:(1)有问题: 可以点击 右边中-在线咨询,左侧qq,旺旺在线联系
         (2)感兴趣: 可以点击 左侧中-分享到

Model-Based EtherCAT Communications

EtherCAT Protocol

The Ethernet for Control Automation (EtherCAT) is an open, high-performance Ethernet network protocol for real-time distributed control. You can use an EtherCAT network instead of an Ethernet network because the EtherCAT protocol provides:

  • Deterministic and fast cycle times

  • Inexpensive hardware cost

EtherCAT networks consist of one master node and several slave nodes. The xPC Target EtherCAT sublibrary supports only the master node of an EtherCAT network. In other words, you cannot emulate slave nodes using these blocks. However, you can prototype multiple EtherCAT controllers, with multiple Ethernet cards, using these blocks.

This topic assumes that you:

Before You Start

  1. Provide a dedicated Ethernet card on your target computer. A dedicated Ethernet card is to be used only for model-based EtherCAT communications and not for communication between the host computer and target computer. This requirement means that your target computer must have at least two Ethernet cards, one for host computer to target computer communications, and one for model-based EtherCAT communication.

  2. Download or purchase the Beckhoff ET9000 EtherCAT configurator software, available at:

    http://www.beckhoff.com/english.asp?ethercat/et9000_et9200_et9300.htm

  3. Design and configure an EtherCAT network.

  4. Create an EtherCAT configuration XML file for this network. The xPC Target EtherCAT blocks require this configuration XML file.

Basic Workflow

This topic describes a basic workflow for using the xPC Target EtherCAT sublibrary. It assumes that you:

  • Have an EtherCAT network

  • Have access to the EtherCAT configurator software

  • Know how to use the EtherCAT configurator software to create a configuration XML file

See Before You Start for more information.

  1. Connect to the EtherCAT network.

  2. Use the Beckhoff ET9000 configurator to configure the EtherCAT network.

    This step produces a network configuration file, contained in an XML file.

      Note:   The xPC Target documentation does not describe how to use Beckhoff ET9000 configurator software.

  3. From the Beckhoff ET9000 configurator, export the XML configuration file.

  4. In the xPC Target model for the EtherCAT master, add an xPC Target EtherCAT Init block.

      Tip   The xPC Target EtherCAT blocks are not available in the standard xPC Target library. To access these blocks, type xpcethercatlib in the MATLAB Command Window.

  5. Double-click the Init block and enter the configuration file name from step 3 in the EtherCAT configuration file parameter. Use single quotes around the configuration file name.

     

  6. Configure the rest of the block.

  7. Add and configure other EtherCAT blocks, such as the EtherCAT Rx Var and EtherCAT Tx Var blocks. At the very least, each model must contain the EtherCAT Init, EtherCAT Rx Frames, and EtherCAT Update blocks. Add an EtherCAT Rx Var or EtherCAT Tx Var block for every EtherCAT device variable that is linked to a variable in an ET9000 task.

    When you add EtherCAT blocks to the model, the blocks automatically obtain the list of variables from the XML configuration file specified in their associated EtherCAT Init block. The parameter dialog boxes of these blocks are updated with the configuration information.

  8. Repeat steps 1 to 6 for each EtherCAT network that you want. Use a different Ethernet card interface for each EtherCAT network.

Execution Priority

The EtherCAT blocks have the following execution priority, from first to last:

  1. EtherCAT Init

  2. EtherCAT Rx Frames

  3. EtherCAT Rx Var, EtherCAT Tx Var

  4. EtherCAT Update

  5. EtherCAT COE Read, EtherCAT COE Write, EtherCAT Get State, EtherCAT Set State

xPC Target Applications of the Beckhoff ET9000 EtherCAT Configurator

This topic lists the configurator components that have corresponding xPC Target elements. It does not describe how to use the configurator. See the Beckhoff ET9000 EtherCAT Configurator for documentation on how to use the tool.

  • The EtherCAT configuration file that you specify in the EtherCAT Init block describes the network, including the device variables of the network. When you specify a device variable from this network, the block variable information corresponds to signal information on the block mask and block parameter dialog box.

  • If your model contains the EtherCAT COE Read and EtherCAT COE Write blocks, include in the configuration file at least one cyclic input/output task linked to one of the slave device input/output channels.

  • Do not name the configuration file with the name modelname.xml.

  • Create at least one task for data transfers.

  • To perform data transfers at multiple rates, create multiple tasks in the configurator.

    The task rate that you use in the configurator must match the greatest common divisor of the rates in the Simulink model. All tasks run at this rate. The greatest common divisor must be a multiple of the fixed Sample Time defined in the block parameter dialog box, or the fixed Sample Time must be auto.

  • You can create more than one task at the same rate.

ET9000 EtherCAT Configurator Component Corresponding xPC Target Component
Execution rate of EtherCAT task Sample Time/Task Rate
Scalars and vectors Dimension
BitSize Type Size (see EtherCAT Data Types)
Data Type+BitSize Signal Type (see EtherCAT Data Types)
BitOffs − 80 Signal Offset
EtherCAT device variable that is linked to a variable in an ET9000 task EtherCAT Rx VarSignal Name
Task scheduling EtherCAT UpdateTask priorities
Tasks EtherCAT UpdateTask Id List
Each device variable in Process Image entity Depending on purpose, EtherCAT Rx Var or EtherCAT Tx Var block

 

EtherCAT Chip Sets

The xPC Target EtherCAT communication blocks support the following Intel (Vendor ID 0x8086) chips:

Device ID Chip Description
0x1013 I82541EI COPPER
0x1078 I82541ER
0x1076 I82541GI COPPER
0x107C I82541PI DESKTOP
0x1019 I82547GI COPPER
0x1026 I82545GM COPPER
0x10BD I82566L
0x10A7 I82575 ZOAR
0x1075 I82547EI
0x108C I82573
0x10B9 I82572GI
0x10A4 I82571GB QUAD
0x10D3 I82574L
0x1229 Intel PRO/100 M Desktop Adapter: 82557, 82558, 82559, 82550, 82551
0x1209 Fast Ethernet Controller: 82551xER, 82551IT
0x1059 Fast Ethernet PCI Controller: 82551QM
0x2449 Integrated 10Base-T/100Base-T TX Ethernet Controller: 8x559ER
0x103A LAN Controller: 82562ET, 82562EZ, 82563ET, 82801DB
0x1039 LAN Controller: 82562ET, 82562EZ, 82562VE, 82562VM
0x1050 Pro/100 VE Network Connection: 8201EB, 8201ER
0x27DC Intel PRO/100 VE Desktop Adapter: 82562V

 

EtherCAT Data Types

The xPC Target EtherCAT blocks support the following EtherCAT data types:

EtherCAT Data Type Data Type Size (bits) Converted Simulink Data Type
bit 1 uint8
bit8 8 uint8
bitarr 8 (bit array) uint8
bitarr16 16 (bit array) uint16
bitarr32 32 (bit array) uint32
BOOL 1 Boolean
int8 8 int8
int16 16 int16
int32 32 int32
int64 64 Not available
uint8 8 uint8
uint16 16 uint16
uint32 32 uint32
uint64 64 Not available
float 32 real32_T
double 64 real_T

 

EtherCAT Error Values

The xPC Target EtherCAT blocks return the following EtherCAT error values:

Error Value Description
65537 (0x10001) Cyclic command: working counter error
65538 (0x10002) Master init command: working counter error
65539 (0x10003) Slave init command: working counter error
65540 (0x10004) EOE mbox receive: working counter error
65541 (0x10005) COE mbox receive: working counter error
65542 (0x10006) FOE mbox receive: working counter error
65543 (0x10007) EOE mbox send: working counter error
65544 (0x10008) COE mbox send: working counter error
65545 (0x10009) FOE mbox send: working counter error
65546 (0x1000a) Got no response on a sent Ethernet frame
65547 (0x1000b) Got no response on a sent ecat init command from slave
65548 (0x1000c) Got no response on a sent ecat master init command
65549 (0x1000d) Missing ecat command in received ethernet frame
65550 (0x1000e) Timeout when waiting for mailbox init command response
65551 (0x1000f) Not all slave devices are in operational state when receiving cyclic frames
65552 (0x10010) Ethernet link (cable) not connected
65553 (0x10011) Obsolete
65554 (0x10012) Redundancy: line break detected
65555 (0x10013) At least one slave is in error state when receiving cyclic frames (BRD AL-STATUS)
65556 (0x10014) Slave error status information
65557 (0x10015) Fixed station address lost (or slave missing) - FPRD to AL_STATUS failed
65558 (0x10016) SOE mbox receive: working counter error
65559 (0x10017) SOE mbox send: working counter error
65560 (0x10018) SOE mbox write responded with an error
65561 (0x10019) COE mbox SDO abort
65562 (0x1001a) Client registration dropped, possibly call to ecatConfigureMaster by other thread (RAS)
65563 (0x1001b) Redundancy: line is repaired
65564 (0x1001c) FOE mbox abort